//
//  EXRootViewController.m
//  Exercise
//
//  Created by 羊谦 on 16/5/31.
//  Copyright © 2016年 NetEase-yangqian. All rights reserved.
//

#import "EXRootViewController.h"
#import "EXMainViewController.h"
#import "EXLoginViewController.h"
#import "EXLoginManager.h"

@interface EXRootViewController ()
{
@private
    UIViewController *_currentViewController;
}
@end

@implementation EXRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _currentViewController = [self createCurrentViewController];
    [self.view addSubview:_currentViewController.view];
    [self addChildViewController:_currentViewController];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    _currentViewController.view.frame = self.view.frame;
}

- (UIViewController *)createCurrentViewController {
    if ([EXLoginManager isLogin]) {
        EXMainViewController *mainViewController = [[EXMainViewController alloc] init];
        return mainViewController;
    }
    EXLoginViewController *loginViewController = [[EXLoginViewController alloc] init];
    return loginViewController;
}

@end
